import os
import sys
import logging

# 设置日志
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

def verify_imports():
    """验证导入是否正常工作"""
    try:
        # 尝试导入GenerateReplyPrompt类
        from generate_reply_prompt import GenerateReplyPrompt
        logger.info("成功导入GenerateReplyPrompt类")
        
        # 尝试初始化GenerateReplyPrompt类
        prompt_generator = GenerateReplyPrompt()
        logger.info("成功初始化GenerateReplyPrompt类")
        
        # 尝试加载人格定义
        personality_def = prompt_generator.personality_definition
        if personality_def:
            logger.info(f"成功加载人格定义，包含的维度：{list(personality_def.get('personality_dimensions', {}).keys())}")
        else:
            logger.warning("人格定义加载为空")
        
        # 测试生成提示词功能
        test_patient_info = {"姓名": "测试患者", "年龄": "40岁"}
        test_question = "您感觉哪里不舒服？"
        test_history = [{"医生": "您好！", "患者": "您好，医生！"}]
        test_personality = {"性格": "合作", "情绪状态": "平稳"}
        
        prompt = prompt_generator.generate_prompt(
            patient_info=test_patient_info,
            doctor_question=test_question,
            conversation_history=test_history,
            target_personality=test_personality
        )
        
        logger.info("成功生成提示词")
        logger.info(f"提示词长度: {len(prompt)} 字符")
        
        # 测试记忆约束功能
        test_answer = "我感觉头痛，已经持续了两天。"
        constrained_answer = prompt_generator.apply_memory_constraints(
            question=test_question,
            base_answer=test_answer,
            persona={"病史回忆能力": "高"}
        )
        
        logger.info("成功应用记忆约束")
        logger.info("验证成功完成！")
        
    except Exception as e:
        logger.error(f"验证失败: {str(e)}")
        raise

if __name__ == "__main__":
    verify_imports()